﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

namespace SG {

    public sealed class MonoPInvokeCallbackAttribute : Attribute
    {
        public MonoPInvokeCallbackAttribute(Type t)
        {
        }
    }

    /**
     * 简单工具类
     */
    public static class NativeUtils
    {
        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetPackageName()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetPackageName");
#else
        return "";
#endif
        }

        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetPackageVersion()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetPackageVersion");
#else
        return "";
#endif
        }

        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetPackagePath()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetPackagePath");
#else
        return "";
#endif
        }

        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetPackageSignature()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetPackageSignature");
#else
        return "";
#endif
        }

        [MonoPInvokeCallbackAttribute(typeof(Func<string, string>))]
        static public string GetPackageMetaData(string name)
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>( "GetPackageMetaData", name);
#else
        return "";
#endif
        }
        
        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetPersistentDataPath()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetPersistentDataPath");
#else
        return Application.persistentDataPath;
#endif
        }

        [MonoPInvokeCallbackAttribute(typeof(Func<string>))]
        static public string GetInternalDataPath()
        {
#if UNITY_ANDROID
            return NativeAndroid.CallMethodStatic<string>("GetInternalDataPath");
#else
        return Application.persistentDataPath;
#endif
        }
    }
}
